// TypeScript file
module view{
    export class GameViewJoinRoomPanel extends eui.Component {
            public userID: eui.Label
            public history: eui.Label
            public totle: eui.Label
            public moshi: eui.Label
            public difen: eui.Label
            public wanfa: eui.Label
            public jushu: eui.Label
            public room: eui.Label
            public greatroom: eui.Button
            public joinroom: eui.Button
            
            public constructor(){
                super();
                this.skinName=view.GameViewJoinRoom;

                this.greatroom.addEventListener(egret.TouchEvent.TOUCH_TAP, this.GreatRoom, this)
                this.joinroom.addEventListener(egret.TouchEvent.TOUCH_TAP, this.JoinRoom, this)
            }
            public setData(data:any):void{
                this.userID.text = window.localStorage.getItem("account_id")
                if(view.GameViewPlay.globalData["data"]){
                    this.history.text="历史最高分："+view.GameViewPlay.globalData["data"]["historyInfo"]["score"]+"("+view.GameViewPlay.globalData["data"]["historyInfo"]["time"]+")"
                    this.totle.text="游戏总局数："+view.GameViewPlay.globalData["data"]["historyInfo"]["total_count"]
                }
                if(data['banker_mode']==3){
                    this.moshi.text="模式：自由抢庄"
                }else if(data['banker_mode']==5){
                    this.moshi.text="模式：大混战"
                }else{
                     this.moshi.text="模式：九点上庄"
                }//庄家模式
                this.difen.text="底分："+data['score_type']+"分";
                if(data['rule_type']==1){
                    this.wanfa.text="玩法：有大小王"
                }else{
                    this.wanfa.text="玩法：无大小王"
                }              
                if(data["ticket_type"]==1){
                    this.jushu.text="局数：10（x2房卡）";
                }
                if(data["ticket_type"]==2){
                    this.jushu.text="局数：20（x4房卡）";
                }
                this.room.text=data['alert_text']
            }
            private GreatRoom(e: egret.TouchEvent): void {//创建房间
                if (window["go"]) {
                    window["go"]("http://www.kw08.cn/game.php/index/index69.html");
                }
            }
            private JoinRoom(e: egret.TouchEvent): void {//加入房间
                var soket:tool.GameWebSocket = tool.GameWebSocket.getSocket();
                soket.sendMessage(tool.SendData.sendJoinRoomData())
            }
    }
}